<?php

include _ITSTOCK_INCLUDE_DIR_.'html_options.inc.php';

itstock_structure($structure, 'product');
$edit = false;

if(isset($_POST['id'])){
    $structure['where'][0] = sprintf("`%s`.`id`='%s'", $structure['table'], itstock_decode($_POST['id']));
    $edit = itstock_search_all($structure);
}

?><b><?php echo (!$edit?'New ':'')?>Product</b>
  <br><br><br>
<form class="save" action="store.php?type=product" method="POST" id="form_product" autocomplete="off">
  <input type="hidden" value="<?php echo ($edit?itstock_encode($structure['data'][0]['id']):'')?>" id="id" name="id">
  <table>
    <tr>
      <td><label>Vendor:</label></td>
      <td><select name="vendor_id" id="vendor_id" required ><?php
        itstock_html_options('vendor', 'vendor', 'vendor_id', $structure, $edit);
      ?></select>
      </td>
    </tr>
    <tr>
      <td><label>Product:</label></td>
      <td><input type="text" autofocus name="product" style="width: 200px" value="<?php echo ($edit?$structure['data'][0]['product']:'')?>" required placeholder="Product"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><br><input type="submit" value="Save" style="margin-right: 100px;"><input type="reset" value="Reset"></td>
    </tr>
  </table>
</form>
